#pragma once

#include "TestIdentityAction.h"

#include "InputPin.h"
#include "OutputPin.h"

namespace uml {

TestIdentityAction::TestIdentityAction(const QString& umlType)
    : Action(umlType) {}

void TestIdentityAction::fromJson(const QJsonObject& json, QStringList& errorList) {
    if (json.isEmpty()) {
        return;
    }

    Action::fromJson(json, errorList);
    first_ = JsonSerializable::create<InputPin>(json.value("first"), errorList);

    result_ = JsonSerializable::create<OutputPin>(json.value("result"), errorList);

    second_ = JsonSerializable::create<InputPin>(json.value("second"), errorList);

}

void TestIdentityAction::toJson(QJsonObject& json) {
    Action::toJson(json);
    if (first_) {
        QJsonObject first_json;
        first_->toJson(first_json);
        json.insert("first", first_json);
    }
    if (result_) {
        QJsonObject result_json;
        result_->toJson(result_json);
        json.insert("result", result_json);
    }
    if (second_) {
        QJsonObject second_json;
        second_->toJson(second_json);
        json.insert("second", second_json);
    }
}

/// <summary>
/// first getter
/// The InputPin on which the first input object is placed.
/// </summary>
shared_ptr<InputPin> TestIdentityAction::first() const {
    return first_;
}

/// <summary>
/// first setter
/// The InputPin on which the first input object is placed.
/// </summary>
void TestIdentityAction::setFirst(shared_ptr<InputPin> value) {
    first_ = value;
}

/// <summary>
/// result getter
/// The OutputPin whose Boolean value indicates whether the two input objects are
/// identical.
/// </summary>
shared_ptr<OutputPin> TestIdentityAction::result() const {
    return result_;
}

/// <summary>
/// result setter
/// The OutputPin whose Boolean value indicates whether the two input objects are
/// identical.
/// </summary>
void TestIdentityAction::setResult(shared_ptr<OutputPin> value) {
    result_ = value;
}

/// <summary>
/// second getter
/// The OutputPin on which the second input object is placed.
/// </summary>
shared_ptr<InputPin> TestIdentityAction::second() const {
    return second_;
}

/// <summary>
/// second setter
/// The OutputPin on which the second input object is placed.
/// </summary>
void TestIdentityAction::setSecond(shared_ptr<InputPin> value) {
    second_ = value;
}

} // namespace uml
